import "package:flutter/material.dart";

class UseRefresh extends StatefulWidget {
  final Widget child;
  final Future<void> Function() onRefresh;
  const UseRefresh({super.key, required this.child, required this.onRefresh});
  @override
  State<StatefulWidget> createState() => _UseRefreshState();
}

class _UseRefreshState extends State<UseRefresh> {
  @override
  Widget build(BuildContext context) {
    return RefreshIndicator(
      edgeOffset: -30, //距离顶部偏移量
      triggerMode: RefreshIndicatorTriggerMode.onEdge, //触发模式
      onRefresh: () async {
        await widget.onRefresh();
        return Future.value();
      },
      child: widget.child,
    );
  }
}
